package LeetCode.interview;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;




import LeetCode.interview._002_Add_Two_Numbers.ListNode;
import sun.tools.jar.resources.jar;
import util.LogUtils;
import util.datastructure.TreeNode;

/*
 * 
原题　
	 Write a function to delete a node (except the tail) in a singly linked list, given only access to that node.

Supposed the linked list is 1 -> 2 -> 3 -> 4 and you are given the third node with value 3, the linked list should become 1 -> 2 -> 4 after calling your function. 
解题思路
	将要删除的元素的下一个元素赋值为当前元素，然后删除下一个元素
 * @Date 2017-09-27 14：03
 */
public class _237_Delete_Node_in_a_Linked_List {
	/**
	 * 注：传进来的node 就是要删除的节点
	 * @param node
	 */
    public void deleteNode(ListNode node) {
        if (node==null || node.next==null)	return;
        node.val = node.next.val;
        node.next = node.next.next;
    }
	public static void main(String[] args) {
		_237_Delete_Node_in_a_Linked_List obj = new _237_Delete_Node_in_a_Linked_List();

	}

}
